/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wf.ui;

import bc.swing.pfrm.Model;
import bc.swing.pfrm.Page;
import bc.swing.pfrm.ano.Action;
import bc.swing.pfrm.ano.PageDef;
import bc.swing.pfrm.ano.Param;
import bc.swing.pfrm.layouts.FormLayout;
import bc.swing.pfrm.viewtypes.ParamType;
import javax.swing.JPanel;
import wf.model.User;
import wf.ui.windows.Dialog;

/**
 *
 * @author bennyl
 */
@PageDef(name="Login", icon="login64", layout=FormLayout.class)
public class Login extends Model{
    User user = new User();
    String password = "";
    
    @Param(name = "User Name", type= ParamType.STRING, num=0)
    public String getUname() {
        return user.getName();
    }

    public void setUname(String uname) {
        this.user.setName(uname);
    }

    @Param(name="Password", type= ParamType.PASSWORD, num=1)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    @Action(name=Dialog.OK_ACTION)
    void handleOK(){
        syncFromView();
        Page.get(this).disposeView();
    }
    
    @Action(name=Dialog.CANCEL_ACTION)
    void handleCancel(){
        Page.get(this).disposeView();
        user = null;
    }

    public User getUser() {
        return user;
    }

    @Override
    public void configurePageLayout(JPanel layout) {
        ((FormLayout)layout).setColorLabels(false);
        
    }
    
}
